import re

phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d')
# phoneNumRegex = re.compile(r'\d{3}-\d\{3}-\d{4}')
# phoneNumRegex = re.compile('\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d')

# Match对象
mo = phoneNumRegex.search('Call me at 415-555-7973 tomorrow. 234-435-3458 is my office.')
print(mo.group())

phoneNumRegex = re.compile(r'(\d\d\d)-(\d\d\d-\d\d\d\d)')
# phoneNumRegex = re.compile(r'\d{3}-\d\{3}-\d{4}')
# phoneNumRegex = re.compile('\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d')

# Match对象
mo2 = phoneNumRegex.search('Call me at 415-555-7973 tomorrow. 234-435-3458 is my office.')
print('区号：'+ mo2.group(1))
print('电话号码：'+ mo2.group(2))
print('完整号码：'+ mo2.group(0))

mo3 = phoneNumRegex.search('Call me at 415-555-7973 tomorrow. 234-435-3458 is my office.')
areaNum, mainNum = mo3.groups()
print(areaNum)
print(mainNum)
